#include <stdio.h>
#include <unistd.h>
#include "mystdio.h"
#include <string.h>


int main()
{
  MY_FILE* fp = my_fopen("log.txt", "w");
  if(fp == NULL)
  {
    perror("open fail:");
    return 1;
  }

  //进行写操作
  const char* str = "holle world!";
  int cnt = 5;
  while(cnt)
  {
    char ch[1024];
    //snprintf(ch, sizeof(ch), "%s:%d\n", str, cnt--);
    snprintf(ch, sizeof(ch), "%s:%d", str, cnt--);
    
    size_t n = my_fwrite(ch, strlen(ch), 1, fp);
    printf("sucess,当前写入%lu个字节\n", n);
    my_fflush(fp);
    sleep(1);
  }

  return 0;
}
